package com.mob.tools.utils;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.UiModeManager;
import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.location.Location;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Environment;
import android.os.IBinder;
import android.os.Parcel;
import android.os.SystemClock;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.Base64;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import com.mob.tools.MobLog;
import com.mob.tools.log.NLog;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Method;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.json.JSONArray;
import org.json.JSONException;

public class DeviceHelper
{
  private static DeviceHelper deviceHelper;
  private Context context;

  private DeviceHelper(Context paramContext)
  {
    this.context = paramContext.getApplicationContext();
  }

  private String getCurrentNetworkHardwareAddress()
    throws Throwable
  {
    Enumeration localEnumeration1 = NetworkInterface.getNetworkInterfaces();
    if (localEnumeration1 == null)
      return null;
    byte[] arrayOfByte;
    do
    {
      NetworkInterface localNetworkInterface;
      InetAddress localInetAddress;
      do
      {
        Iterator localIterator1 = Collections.list(localEnumeration1).iterator();
        Iterator localIterator2;
        while (!localIterator2.hasNext())
        {
          Enumeration localEnumeration2;
          do
          {
            if (!localIterator1.hasNext())
              break;
            localNetworkInterface = (NetworkInterface)localIterator1.next();
            localEnumeration2 = localNetworkInterface.getInetAddresses();
          }
          while (localEnumeration2 == null);
          localIterator2 = Collections.list(localEnumeration2).iterator();
        }
        localInetAddress = (InetAddress)localIterator2.next();
      }
      while ((localInetAddress.isLoopbackAddress()) || (!(localInetAddress instanceof Inet4Address)));
      arrayOfByte = localNetworkInterface.getHardwareAddress();
    }
    while (arrayOfByte == null);
    StringBuilder localStringBuilder = new StringBuilder();
    int i = arrayOfByte.length;
    for (int j = 0; j < i; j++)
    {
      byte b = arrayOfByte[j];
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = Byte.valueOf(b);
      localStringBuilder.append(String.format("%02x:", arrayOfObject));
    }
    if (localStringBuilder.length() > 0)
      localStringBuilder.deleteCharAt(-1 + localStringBuilder.length());
    return localStringBuilder.toString();
    return null;
  }

  // ERROR //
  private String getHardwareAddressFromShell(String paramString)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: new 103	java/io/BufferedReader
    //   5: dup
    //   6: new 105	java/io/InputStreamReader
    //   9: dup
    //   10: invokestatic 111	java/lang/Runtime:getRuntime	()Ljava/lang/Runtime;
    //   13: new 69	java/lang/StringBuilder
    //   16: dup
    //   17: invokespecial 70	java/lang/StringBuilder:<init>	()V
    //   20: ldc 113
    //   22: invokevirtual 88	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   25: aload_1
    //   26: invokevirtual 88	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   29: ldc 115
    //   31: invokevirtual 88	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   34: invokevirtual 99	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   37: invokevirtual 119	java/lang/Runtime:exec	(Ljava/lang/String;)Ljava/lang/Process;
    //   40: invokevirtual 125	java/lang/Process:getInputStream	()Ljava/io/InputStream;
    //   43: invokespecial 128	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   46: invokespecial 131	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   49: astore_3
    //   50: aload_3
    //   51: invokevirtual 134	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   54: astore 10
    //   56: aload 10
    //   58: astore 8
    //   60: aload_3
    //   61: ifnull +94 -> 155
    //   64: aload_3
    //   65: invokevirtual 137	java/io/BufferedReader:close	()V
    //   68: aload 8
    //   70: invokestatic 143	android/text/TextUtils:isEmpty	(Ljava/lang/CharSequence;)Z
    //   73: ifeq +6 -> 79
    //   76: aconst_null
    //   77: astore 8
    //   79: aload 8
    //   81: areturn
    //   82: astore 11
    //   84: goto -16 -> 68
    //   87: astore 4
    //   89: invokestatic 149	com/mob/tools/MobLog:getInstance	()Lcom/mob/tools/log/NLog;
    //   92: aload 4
    //   94: invokevirtual 155	com/mob/tools/log/NLog:d	(Ljava/lang/Throwable;)I
    //   97: pop
    //   98: aconst_null
    //   99: astore 8
    //   101: aload_2
    //   102: ifnull -34 -> 68
    //   105: aload_2
    //   106: invokevirtual 137	java/io/BufferedReader:close	()V
    //   109: aconst_null
    //   110: astore 8
    //   112: goto -44 -> 68
    //   115: astore 9
    //   117: aconst_null
    //   118: astore 8
    //   120: goto -52 -> 68
    //   123: astore 5
    //   125: aload_2
    //   126: ifnull +7 -> 133
    //   129: aload_2
    //   130: invokevirtual 137	java/io/BufferedReader:close	()V
    //   133: aload 5
    //   135: athrow
    //   136: astore 6
    //   138: goto -5 -> 133
    //   141: astore 5
    //   143: aload_3
    //   144: astore_2
    //   145: goto -20 -> 125
    //   148: astore 4
    //   150: aload_3
    //   151: astore_2
    //   152: goto -63 -> 89
    //   155: goto -87 -> 68
    //
    // Exception table:
    //   from	to	target	type
    //   64	68	82	java/lang/Throwable
    //   2	50	87	java/lang/Throwable
    //   105	109	115	java/lang/Throwable
    //   2	50	123	finally
    //   89	98	123	finally
    //   129	133	136	java/lang/Throwable
    //   50	56	141	finally
    //   50	56	148	java/lang/Throwable
  }

  public static DeviceHelper getInstance(Context paramContext)
  {
    try
    {
      if ((deviceHelper == null) && (paramContext != null))
        deviceHelper = new DeviceHelper(paramContext);
      DeviceHelper localDeviceHelper = deviceHelper;
      return localDeviceHelper;
    }
    finally
    {
    }
  }

  private String getLocalDeviceKey()
    throws Throwable
  {
    if (!getSdcardState());
    File localFile3;
    do
    {
      return null;
      File localFile1 = new File(getSdcardPath(), "ShareSDK");
      if (localFile1.exists())
      {
        File localFile2 = new File(localFile1, ".dk");
        if ((localFile2.exists()) && (localFile2.renameTo(new File(R.getCacheRoot(this.context), ".dk"))))
          localFile2.delete();
      }
      localFile3 = new File(R.getCacheRoot(this.context), ".dk");
    }
    while (!localFile3.exists());
    ObjectInputStream localObjectInputStream = new ObjectInputStream(new FileInputStream(localFile3));
    Object localObject = localObjectInputStream.readObject();
    String str = null;
    if (localObject != null)
    {
      boolean bool = localObject instanceof char[];
      str = null;
      if (bool)
        str = String.valueOf((char[])localObject);
    }
    localObjectInputStream.close();
    return str;
  }

  private Object getSystemService(String paramString)
  {
    try
    {
      Object localObject = this.context.getSystemService(paramString);
      return localObject;
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().w(localThrowable);
    }
    return null;
  }

  private boolean is4GMobileNetwork()
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    if (localTelephonyManager == null);
    while (localTelephonyManager.getNetworkType() != 13)
      return false;
    return true;
  }

  private boolean isFastMobileNetwork()
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    if (localTelephonyManager == null)
      return false;
    switch (localTelephonyManager.getNetworkType())
    {
    case 0:
    case 1:
    case 2:
    case 4:
    case 7:
    case 11:
    default:
      return false;
    case 3:
      return true;
    case 5:
      return true;
    case 6:
      return true;
    case 8:
      return true;
    case 10:
      return true;
    case 9:
      return true;
    case 14:
      return true;
    case 12:
      return true;
    case 15:
      return true;
    case 13:
    }
    return true;
  }

  private boolean isSystemApp(PackageInfo paramPackageInfo)
  {
    int i;
    if ((0x1 & paramPackageInfo.applicationInfo.flags) == 1)
    {
      i = 1;
      if ((0x80 & paramPackageInfo.applicationInfo.flags) != 1)
        break label54;
    }
    label54: for (int j = 1; ; j = 0)
    {
      boolean bool;
      if (i == 0)
      {
        bool = false;
        if (j == 0);
      }
      else
      {
        bool = true;
      }
      return bool;
      i = 0;
      break;
    }
  }

  private String[] listNetworkHardwareAddress()
    throws Throwable
  {
    Enumeration localEnumeration = NetworkInterface.getNetworkInterfaces();
    String[] arrayOfString;
    if (localEnumeration == null)
      arrayOfString = null;
    while (true)
    {
      return arrayOfString;
      ArrayList localArrayList1 = Collections.list(localEnumeration);
      HashMap localHashMap = new HashMap();
      Iterator localIterator = localArrayList1.iterator();
      while (localIterator.hasNext())
      {
        NetworkInterface localNetworkInterface = (NetworkInterface)localIterator.next();
        byte[] arrayOfByte = localNetworkInterface.getHardwareAddress();
        if (arrayOfByte != null)
        {
          StringBuilder localStringBuilder = new StringBuilder();
          int j = arrayOfByte.length;
          for (int k = 0; k < j; k++)
          {
            byte b = arrayOfByte[k];
            Object[] arrayOfObject = new Object[1];
            arrayOfObject[0] = Byte.valueOf(b);
            localStringBuilder.append(String.format("%02x:", arrayOfObject));
          }
          if (localStringBuilder.length() > 0)
            localStringBuilder.deleteCharAt(-1 + localStringBuilder.length());
          localHashMap.put(localNetworkInterface.getName(), localStringBuilder.toString());
        }
      }
      ArrayList localArrayList2 = new ArrayList(localHashMap.keySet());
      ArrayList localArrayList3 = new ArrayList();
      ArrayList localArrayList4 = new ArrayList();
      ArrayList localArrayList5 = new ArrayList();
      ArrayList localArrayList6 = new ArrayList();
      ArrayList localArrayList7 = new ArrayList();
      ArrayList localArrayList8 = new ArrayList();
      ArrayList localArrayList9 = new ArrayList();
      while (localArrayList2.size() > 0)
      {
        String str = (String)localArrayList2.remove(0);
        if (str.startsWith("wlan"))
          localArrayList3.add(str);
        else if (str.startsWith("eth"))
          localArrayList4.add(str);
        else if (str.startsWith("rev_rmnet"))
          localArrayList5.add(str);
        else if (str.startsWith("dummy"))
          localArrayList6.add(str);
        else if (str.startsWith("usbnet"))
          localArrayList7.add(str);
        else if (str.startsWith("rmnet_usb"))
          localArrayList8.add(str);
        else
          localArrayList9.add(str);
      }
      Collections.sort(localArrayList3);
      Collections.sort(localArrayList4);
      Collections.sort(localArrayList5);
      Collections.sort(localArrayList6);
      Collections.sort(localArrayList7);
      Collections.sort(localArrayList8);
      Collections.sort(localArrayList9);
      localArrayList2.addAll(localArrayList3);
      localArrayList2.addAll(localArrayList4);
      localArrayList2.addAll(localArrayList5);
      localArrayList2.addAll(localArrayList6);
      localArrayList2.addAll(localArrayList7);
      localArrayList2.addAll(localArrayList8);
      localArrayList2.addAll(localArrayList9);
      arrayOfString = new String[localArrayList2.size()];
      for (int i = 0; i < arrayOfString.length; i++)
        arrayOfString[i] = ((String)localHashMap.get(localArrayList2.get(i)));
    }
  }

  private void saveLocalDeviceKey(String paramString)
    throws Throwable
  {
    if (!getSdcardState())
      return;
    File localFile = new File(R.getCacheRoot(this.context), ".dk");
    if (localFile.exists())
      localFile.delete();
    ObjectOutputStream localObjectOutputStream = new ObjectOutputStream(new FileOutputStream(localFile));
    localObjectOutputStream.writeObject(paramString.toCharArray());
    localObjectOutputStream.flush();
    localObjectOutputStream.close();
  }

  public String Base64AES(String paramString1, String paramString2)
  {
    Object localObject = null;
    try
    {
      localObject = Base64.encodeToString(Data.AES128Encode(paramString2, paramString1), 0);
      if (((String)localObject).contains("\n"))
      {
        String str = ((String)localObject).replace("\n", "");
        localObject = str;
      }
      return localObject;
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().w(localThrowable);
    }
    return localObject;
  }

  public boolean checkPermission(String paramString)
    throws Throwable
  {
    int i;
    if (Build.VERSION.SDK_INT >= 23)
    {
      try
      {
        ReflectHelper.importClass("android.content.Context");
        Integer localInteger = (Integer)ReflectHelper.invokeInstanceMethod(this.context, "checkSelfPermission", new Object[] { paramString });
        if (localInteger == null)
        {
          i = -1;
        }
        else
        {
          int j = localInteger.intValue();
          i = j;
        }
      }
      catch (Throwable localThrowable)
      {
        MobLog.getInstance().d(localThrowable);
        i = -1;
      }
    }
    else
    {
      this.context.checkPermission(paramString, android.os.Process.myPid(), android.os.Process.myUid());
      i = this.context.getPackageManager().checkPermission(paramString, getPackageName());
    }
    while (i != 0)
      return false;
    return true;
  }

  public String getAdvertisingID()
  {
    try
    {
      Intent localIntent = new Intent("com.google.android.gms.ads.identifier.service.START");
      localIntent.setPackage("com.google.android.gms");
      GSConnection localGSConnection = new GSConnection(null);
      this.context.bindService(localIntent, localGSConnection, 1);
      IBinder localIBinder = localGSConnection.takeBinder();
      Parcel localParcel1 = Parcel.obtain();
      Parcel localParcel2 = Parcel.obtain();
      localParcel1.writeInterfaceToken("com.google.android.gms.ads.identifier.internal.IAdvertisingIdService");
      localIBinder.transact(1, localParcel1, localParcel2, 0);
      localParcel2.readException();
      String str = localParcel2.readString();
      localParcel2.recycle();
      localParcel1.recycle();
      MobLog.getInstance().i("getAdvertisingID === " + str, new Object[0]);
      try
      {
        this.context.unbindService(localGSConnection);
        return str;
      }
      catch (Throwable localThrowable2)
      {
        MobLog.getInstance().d(localThrowable2);
        return str;
      }
    }
    catch (Throwable localThrowable1)
    {
      MobLog.getInstance().d(localThrowable1);
    }
    return null;
  }

  public String getAndroidID()
  {
    String str = Settings.Secure.getString(this.context.getContentResolver(), "android_id");
    MobLog.getInstance().i("getAndroidID === " + str, new Object[0]);
    return str;
  }

  public String getAppLanguage()
  {
    return this.context.getResources().getConfiguration().locale.getLanguage();
  }

  public String getAppName()
  {
    String str1 = this.context.getApplicationInfo().name;
    if (str1 != null)
      return str1;
    int i = this.context.getApplicationInfo().labelRes;
    if (i > 0);
    for (String str2 = this.context.getString(i); ; str2 = String.valueOf(this.context.getApplicationInfo().nonLocalizedLabel))
      return str2;
  }

  public int getAppVersion()
  {
    try
    {
      int i = this.context.getPackageManager().getPackageInfo(this.context.getPackageName(), 0).versionCode;
      return i;
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().d(localThrowable);
    }
    return 0;
  }

  public String getAppVersionName()
  {
    try
    {
      String str = this.context.getPackageManager().getPackageInfo(this.context.getPackageName(), 0).versionName;
      return str;
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().d(localThrowable);
    }
    return "1.0";
  }

  public String getBluetoothName()
  {
    try
    {
      BluetoothAdapter localBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
      if ((localBluetoothAdapter != null) && (checkPermission("android.permission.BLUETOOTH")))
      {
        String str = localBluetoothAdapter.getName();
        return str;
      }
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().d(localThrowable);
    }
    return null;
  }

  public String getBssid()
  {
    try
    {
      if (checkPermission("android.permission.ACCESS_WIFI_STATE"))
      {
        WifiManager localWifiManager = (WifiManager)getSystemService("wifi");
        if (localWifiManager == null)
          return null;
        WifiInfo localWifiInfo = localWifiManager.getConnectionInfo();
        if (localWifiInfo != null)
        {
          String str1 = localWifiInfo.getBSSID();
          String str2 = str1;
          if (str2 == null)
            str2 = null;
          return str2;
        }
      }
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().d(localThrowable);
    }
    return null;
  }

  public String getCarrier()
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    String str;
    if (localTelephonyManager == null)
      str = "-1";
    do
    {
      return str;
      str = localTelephonyManager.getSimOperator();
    }
    while (!TextUtils.isEmpty(str));
    return "-1";
  }

  public String getCarrierName()
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    String str;
    if (localTelephonyManager == null)
      str = null;
    while (true)
    {
      return str;
      try
      {
        if (checkPermission("android.permission.READ_PHONE_STATE"))
        {
          str = localTelephonyManager.getSimOperatorName();
          boolean bool = TextUtils.isEmpty(str);
          if (!bool)
            continue;
          return null;
        }
      }
      catch (Throwable localThrowable)
      {
        MobLog.getInstance().w(localThrowable);
      }
    }
    return null;
  }

  public int getCellId()
  {
    try
    {
      if (checkPermission("android.permission.ACCESS_COARSE_LOCATION"))
      {
        TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
        if (localTelephonyManager != null)
        {
          int i = ((GsmCellLocation)localTelephonyManager.getCellLocation()).getCid();
          return i;
        }
      }
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().d(localThrowable);
    }
    return -1;
  }

  public int getCellLac()
  {
    try
    {
      if (checkPermission("android.permission.ACCESS_COARSE_LOCATION"))
      {
        TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
        if (localTelephonyManager != null)
        {
          int i = ((GsmCellLocation)localTelephonyManager.getCellLocation()).getLac();
          return i;
        }
      }
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().d(localThrowable);
    }
    return -1;
  }

  public String getCharAndNumr(int paramInt)
  {
    long l = System.currentTimeMillis() ^ SystemClock.elapsedRealtime();
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append(l);
    Random localRandom = new Random();
    int i = 0;
    if (i < paramInt)
    {
      String str;
      if (localRandom.nextInt(2) % 2 == 0)
      {
        str = "char";
        label58: if (!"char".equalsIgnoreCase(str))
          break label108;
        char c = (char)(97 + localRandom.nextInt(26));
        localStringBuffer.insert(i + 1, c);
      }
      while (true)
      {
        i++;
        break;
        str = "num";
        break label58;
        label108: localStringBuffer.insert(localStringBuffer.length(), localRandom.nextInt(10));
      }
    }
    return localStringBuffer.toString().substring(0, 40);
  }

  public String getDetailNetworkTypeForStatic()
  {
    String str = getNetworkType().toLowerCase();
    if ((TextUtils.isEmpty(str)) || ("none".equals(str)))
      str = "none";
    do
    {
      return str;
      if (str.startsWith("wifi"))
        return "wifi";
      if (str.startsWith("4g"))
        return "4g";
      if (str.startsWith("3g"))
        return "3g";
      if (str.startsWith("2g"))
        return "2g";
    }
    while (!str.startsWith("bluetooth"));
    return "bluetooth";
  }

  public String getDeviceData()
  {
    return Base64AES(getModel() + "|" + getOSVersionInt() + "|" + getManufacturer() + "|" + getCarrier() + "|" + getScreenSize(), getDeviceKey().substring(0, 16));
  }

  public String getDeviceDataNotAES()
  {
    return getModel() + "|" + getOSVersion() + "|" + getManufacturer() + "|" + getCarrier() + "|" + getScreenSize();
  }

  public String getDeviceId()
  {
    String str = getIMEI();
    if ((TextUtils.isEmpty(str)) && (Build.VERSION.SDK_INT >= 9))
      str = getSerialno();
    return str;
  }

  public String getDeviceKey()
  {
    try
    {
      String str7 = getLocalDeviceKey();
      str1 = str7;
      if ((!TextUtils.isEmpty(str1)) && (str1.length() >= 40))
        return str1;
    }
    catch (Throwable localThrowable1)
    {
      while (true)
      {
        MobLog.getInstance().w(localThrowable1);
        String str1 = null;
      }
    }
    try
    {
      String str3 = getMacAddress();
      String str4 = getDeviceId();
      String str5 = getModel();
      String str6 = Data.byteToHex(Data.SHA1(str3 + ":" + str4 + ":" + str5));
      str2 = str6;
      if ((TextUtils.isEmpty(str2)) || (str2.length() < 40))
        str2 = getCharAndNumr(40);
      if (str2 == null);
    }
    catch (Throwable localThrowable2)
    {
      try
      {
        saveLocalDeviceKey(str2);
        return str2;
        localThrowable2 = localThrowable2;
        MobLog.getInstance().d(localThrowable2);
        String str2 = null;
      }
      catch (Throwable localThrowable3)
      {
        while (true)
          MobLog.getInstance().w(localThrowable3);
      }
    }
  }

  public String getDeviceType()
  {
    UiModeManager localUiModeManager = (UiModeManager)getSystemService("uimode");
    if (localUiModeManager != null);
    switch (localUiModeManager.getCurrentModeType())
    {
    default:
      return "UNDEFINED";
    case 1:
      return "NO_UI";
    case 2:
      return "DESK";
    case 3:
      return "CAR";
    case 4:
      return "TELEVISION";
    case 5:
      return "APPLIANCE";
    case 6:
    }
    return "WATCH";
  }

  public String getIMEI()
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    Object localObject;
    if (localTelephonyManager == null)
      localObject = null;
    while (true)
    {
      return localObject;
      try
      {
        boolean bool = checkPermission("android.permission.READ_PHONE_STATE");
        localObject = null;
        if (bool)
        {
          String str = localTelephonyManager.getDeviceId();
          localObject = str;
        }
        if (!TextUtils.isEmpty((CharSequence)localObject))
          continue;
        return null;
      }
      catch (Throwable localThrowable)
      {
        while (true)
        {
          MobLog.getInstance().w(localThrowable);
          localObject = null;
        }
      }
    }
  }

  public String getIMSI()
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    Object localObject;
    if (localTelephonyManager == null)
      localObject = null;
    while (true)
    {
      return localObject;
      try
      {
        boolean bool = checkPermission("android.permission.READ_PHONE_STATE");
        localObject = null;
        if (bool)
        {
          String str = localTelephonyManager.getSubscriberId();
          localObject = str;
        }
        if (!TextUtils.isEmpty((CharSequence)localObject))
          continue;
        return null;
      }
      catch (Throwable localThrowable)
      {
        while (true)
        {
          MobLog.getInstance().w(localThrowable);
          localObject = null;
        }
      }
    }
  }

  public String getIPAddress()
  {
    try
    {
      if (checkPermission("android.permission.INTERNET"))
      {
        InetAddress localInetAddress;
        do
        {
          Enumeration localEnumeration1 = NetworkInterface.getNetworkInterfaces();
          Enumeration localEnumeration2;
          while (!localEnumeration2.hasMoreElements())
          {
            if (!localEnumeration1.hasMoreElements())
              break;
            localEnumeration2 = ((NetworkInterface)localEnumeration1.nextElement()).getInetAddresses();
          }
          localInetAddress = (InetAddress)localEnumeration2.nextElement();
        }
        while ((localInetAddress.isLoopbackAddress()) || (!(localInetAddress instanceof Inet4Address)));
        String str = localInetAddress.getHostAddress();
        return str;
      }
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().w(localThrowable);
    }
    return "0.0.0.0";
  }

  public ArrayList<HashMap<String, String>> getInstalledApp(boolean paramBoolean)
  {
    ArrayList localArrayList;
    try
    {
      PackageManager localPackageManager = this.context.getPackageManager();
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = Integer.valueOf(0);
      List localList = (List)ReflectHelper.invokeInstanceMethod(localPackageManager, "getInstalledPackages", arrayOfObject);
      localArrayList = new ArrayList();
      Iterator localIterator = localList.iterator();
      while (localIterator.hasNext())
      {
        PackageInfo localPackageInfo = (PackageInfo)localIterator.next();
        if ((paramBoolean) || (!isSystemApp(localPackageInfo)))
        {
          HashMap localHashMap = new HashMap();
          localHashMap.put("pkg", localPackageInfo.packageName);
          String str = localPackageInfo.applicationInfo.name;
          if (str == null)
          {
            int i = localPackageInfo.applicationInfo.labelRes;
            if (i > 0)
            {
              CharSequence localCharSequence = localPackageManager.getText(localPackageInfo.packageName, i, localPackageInfo.applicationInfo);
              if (localCharSequence != null)
                str = localCharSequence.toString().trim();
            }
            if (str == null)
              str = String.valueOf(localPackageInfo.applicationInfo.nonLocalizedLabel);
          }
          localHashMap.put("name", str);
          localHashMap.put("version", localPackageInfo.versionName);
          localArrayList.add(localHashMap);
        }
      }
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().w(localThrowable);
      localArrayList = new ArrayList();
    }
    return localArrayList;
  }

  public String getLine1Number()
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    if (localTelephonyManager == null)
      return "-1";
    return localTelephonyManager.getLine1Number();
  }

  public Location getLocation(int paramInt1, int paramInt2, boolean paramBoolean)
  {
    try
    {
      if (checkPermission("android.permission.ACCESS_FINE_LOCATION"))
      {
        Location localLocation = new LocationHelper().getLocation(this.context, paramInt1, paramInt2, paramBoolean);
        return localLocation;
      }
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().d(localThrowable);
    }
    return null;
  }

  public float[] getLocation(int paramInt1, int paramInt2)
  {
    Location localLocation = getLocation(paramInt1, paramInt2, true);
    if (localLocation != null)
    {
      float[] arrayOfFloat = new float[2];
      arrayOfFloat[0] = ((float)localLocation.getLatitude());
      arrayOfFloat[1] = ((float)localLocation.getLongitude());
      return arrayOfFloat;
    }
    return null;
  }

  public String getMCC()
  {
    if ((TelephonyManager)getSystemService("phone") == null);
    String str;
    do
    {
      return null;
      str = getIMSI();
    }
    while ((str == null) || (str.length() < 3));
    return str.substring(0, 3);
  }

  public String getMNC()
  {
    if ((TelephonyManager)getSystemService("phone") == null);
    String str;
    do
    {
      return null;
      str = getIMSI();
    }
    while ((str == null) || (str.length() < 5));
    return str.substring(3, 5);
  }

  public String getMacAddress()
  {
    if (Build.VERSION.SDK_INT >= 23);
    WifiInfo localWifiInfo;
    do
    {
      WifiManager localWifiManager;
      do
      {
        try
        {
          String str3 = getHardwareAddressFromShell("wlan0");
          localObject2 = str3;
          if (localObject2 != null);
        }
        catch (Throwable localThrowable3)
        {
          try
          {
            String str2 = getCurrentNetworkHardwareAddress();
            localObject2 = str2;
            if (localObject2 != null);
          }
          catch (Throwable localThrowable3)
          {
            try
            {
              while (true)
              {
                String[] arrayOfString = listNetworkHardwareAddress();
                if (arrayOfString.length > 0)
                  localObject2 = arrayOfString[0];
                if (localObject2 == null)
                  break;
                localObject1 = localObject2;
                return localObject1;
                localThrowable1 = localThrowable1;
                MobLog.getInstance().d(localThrowable1);
                localObject2 = null;
              }
              localThrowable3 = localThrowable3;
              MobLog.getInstance().d(localThrowable3);
              localObject2 = null;
            }
            catch (Throwable localThrowable2)
            {
              while (true)
              {
                MobLog.getInstance().d(localThrowable2);
                Object localObject2 = null;
              }
            }
          }
        }
        localWifiManager = (WifiManager)getSystemService("wifi");
        localObject1 = null;
      }
      while (localWifiManager == null);
      localWifiInfo = localWifiManager.getConnectionInfo();
      Object localObject1 = null;
    }
    while (localWifiInfo == null);
    String str1 = localWifiInfo.getMacAddress();
    if (str1 == null)
      str1 = null;
    return str1;
  }

  public String getManufacturer()
  {
    return Build.MANUFACTURER;
  }

  public String getMime()
  {
    return getIMEI();
  }

  public String getModel()
  {
    return Build.MODEL;
  }

  public String getNetworkOperator()
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    if (localTelephonyManager == null)
      return null;
    return localTelephonyManager.getNetworkOperator();
  }

  public String getNetworkType()
  {
    ConnectivityManager localConnectivityManager = (ConnectivityManager)getSystemService("connectivity");
    if (localConnectivityManager == null)
      return "none";
    try
    {
      if (!checkPermission("android.permission.ACCESS_NETWORK_STATE"))
        return "none";
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().w(localThrowable);
      return "none";
    }
    NetworkInfo localNetworkInfo = localConnectivityManager.getActiveNetworkInfo();
    if ((localNetworkInfo == null) || (!localNetworkInfo.isAvailable()))
      return "none";
    int i = localNetworkInfo.getType();
    switch (i)
    {
    case 2:
    case 3:
    case 4:
    case 5:
    default:
      return String.valueOf(i);
    case 1:
      return "wifi";
    case 0:
      if (is4GMobileNetwork())
        return "4G";
      if (isFastMobileNetwork())
        return "3G";
      return "2G";
    case 7:
      return "bluetooth";
    case 8:
      return "dummy";
    case 9:
      return "ethernet";
    case 6:
    }
    return "wimax";
  }

  public String getNetworkTypeForStatic()
  {
    String str = getNetworkType().toLowerCase();
    if ((TextUtils.isEmpty(str)) || ("none".equals(str)))
      return "none";
    if ((str.startsWith("4g")) || (str.startsWith("3g")) || (str.startsWith("2g")))
      return "cell";
    if (str.startsWith("wifi"))
      return "wifi";
    return "other";
  }

  public String getOSCountry()
  {
    return Locale.getDefault().getCountry();
  }

  public String getOSLanguage()
  {
    return Locale.getDefault().getLanguage();
  }

  public String getOSVersion()
  {
    return String.valueOf(getOSVersionInt());
  }

  public int getOSVersionInt()
  {
    return Build.VERSION.SDK_INT;
  }

  public String getOSVersionName()
  {
    return Build.VERSION.RELEASE;
  }

  public String getPackageName()
  {
    return this.context.getPackageName();
  }

  public int getPlatformCode()
  {
    return 1;
  }

  public JSONArray getRunningApp()
  {
    JSONArray localJSONArray = new JSONArray();
    ActivityManager localActivityManager = (ActivityManager)getSystemService("activity");
    if (localActivityManager == null);
    while (true)
    {
      return localJSONArray;
      List localList = localActivityManager.getRunningAppProcesses();
      if (localList != null)
      {
        Iterator localIterator = localList.iterator();
        while (localIterator.hasNext())
          localJSONArray.put(((ActivityManager.RunningAppProcessInfo)localIterator.next()).processName);
      }
    }
  }

  public String getRunningAppStr()
    throws JSONException
  {
    JSONArray localJSONArray = getRunningApp();
    StringBuilder localStringBuilder = new StringBuilder();
    for (int i = 0; i < localJSONArray.length(); i++)
    {
      if (i > 0)
        localStringBuilder.append(',');
      localStringBuilder.append(String.valueOf(localJSONArray.get(i)));
    }
    return localStringBuilder.toString();
  }

  public String getSSID()
  {
    try
    {
      if (checkPermission("android.permission.ACCESS_WIFI_STATE"))
      {
        WifiManager localWifiManager = (WifiManager)getSystemService("wifi");
        if (localWifiManager == null)
          return null;
        WifiInfo localWifiInfo = localWifiManager.getConnectionInfo();
        if (localWifiInfo != null)
        {
          String str1 = localWifiInfo.getSSID().replace("\"", "");
          String str2 = str1;
          if (str2 == null)
            str2 = null;
          return str2;
        }
      }
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().d(localThrowable);
    }
    return null;
  }

  public String getScreenSize()
  {
    int[] arrayOfInt = R.getScreenSize(this.context);
    if (this.context.getResources().getConfiguration().orientation == 1)
      return arrayOfInt[0] + "x" + arrayOfInt[1];
    return arrayOfInt[1] + "x" + arrayOfInt[0];
  }

  public String getSdcardPath()
  {
    return Environment.getExternalStorageDirectory().getAbsolutePath();
  }

  public boolean getSdcardState()
  {
    try
    {
      boolean bool1 = checkPermission("android.permission.WRITE_EXTERNAL_STORAGE");
      boolean bool2 = false;
      if (bool1)
      {
        boolean bool3 = "mounted".equals(Environment.getExternalStorageState());
        bool2 = false;
        if (bool3)
          bool2 = true;
      }
      return bool2;
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().w(localThrowable);
    }
    return false;
  }

  public String getSerialno()
  {
    int i = Build.VERSION.SDK_INT;
    String str = null;
    if (i >= 9);
    try
    {
      Class localClass = Class.forName("android.os.SystemProperties");
      str = (String)localClass.getMethod("get", new Class[] { String.class, String.class }).invoke(localClass, new Object[] { "ro.serialno", "unknown" });
      return str;
    }
    catch (Throwable localThrowable)
    {
      MobLog.getInstance().d(localThrowable);
    }
    return null;
  }

  public String getSignMD5()
  {
    try
    {
      String str = Data.MD5(this.context.getPackageManager().getPackageInfo(getPackageName(), 64).signatures[0].toByteArray());
      return str;
    }
    catch (Exception localException)
    {
      MobLog.getInstance().w(localException);
    }
    return null;
  }

  public String getSimSerialNumber()
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    if (localTelephonyManager == null)
      return "-1";
    return localTelephonyManager.getSimSerialNumber();
  }

  // ERROR //
  public String getTopTaskPackageName()
  {
    // Byte code:
    //   0: aload_0
    //   1: ldc_w 990
    //   4: invokevirtual 547	com/mob/tools/utils/DeviceHelper:checkPermission	(Ljava/lang/String;)Z
    //   7: istore 8
    //   9: iload 8
    //   11: istore_3
    //   12: iload_3
    //   13: ifeq +107 -> 120
    //   16: aload_0
    //   17: ldc_w 893
    //   20: invokespecial 223	com/mob/tools/utils/DeviceHelper:getSystemService	(Ljava/lang/String;)Ljava/lang/Object;
    //   23: checkcast 895	android/app/ActivityManager
    //   26: astore 6
    //   28: aload 6
    //   30: ifnonnull +19 -> 49
    //   33: aconst_null
    //   34: areturn
    //   35: astore_1
    //   36: invokestatic 149	com/mob/tools/MobLog:getInstance	()Lcom/mob/tools/log/NLog;
    //   39: aload_1
    //   40: invokevirtual 219	com/mob/tools/log/NLog:w	(Ljava/lang/Throwable;)I
    //   43: pop
    //   44: iconst_0
    //   45: istore_3
    //   46: goto -34 -> 12
    //   49: getstatic 359	android/os/Build$VERSION:SDK_INT	I
    //   52: bipush 20
    //   54: if_icmpgt +25 -> 79
    //   57: aload 6
    //   59: iconst_1
    //   60: invokevirtual 994	android/app/ActivityManager:getRunningTasks	(I)Ljava/util/List;
    //   63: iconst_0
    //   64: invokeinterface 995 2 0
    //   69: checkcast 997	android/app/ActivityManager$RunningTaskInfo
    //   72: getfield 1001	android/app/ActivityManager$RunningTaskInfo:topActivity	Landroid/content/ComponentName;
    //   75: invokevirtual 1004	android/content/ComponentName:getPackageName	()Ljava/lang/String;
    //   78: areturn
    //   79: aload 6
    //   81: invokevirtual 899	android/app/ActivityManager:getRunningAppProcesses	()Ljava/util/List;
    //   84: iconst_0
    //   85: invokeinterface 995 2 0
    //   90: checkcast 901	android/app/ActivityManager$RunningAppProcessInfo
    //   93: getfield 904	android/app/ActivityManager$RunningAppProcessInfo:processName	Ljava/lang/String;
    //   96: ldc_w 701
    //   99: invokevirtual 1008	java/lang/String:split	(Ljava/lang/String;)[Ljava/lang/String;
    //   102: iconst_0
    //   103: aaload
    //   104: astore 7
    //   106: aload 7
    //   108: areturn
    //   109: astore 4
    //   111: invokestatic 149	com/mob/tools/MobLog:getInstance	()Lcom/mob/tools/log/NLog;
    //   114: aload 4
    //   116: invokevirtual 219	com/mob/tools/log/NLog:w	(Ljava/lang/Throwable;)I
    //   119: pop
    //   120: aconst_null
    //   121: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   0	9	35	java/lang/Throwable
    //   16	28	109	java/lang/Throwable
    //   49	79	109	java/lang/Throwable
    //   79	106	109	java/lang/Throwable
  }

  public void hideSoftInput(View paramView)
  {
    Object localObject = getSystemService("input_method");
    if (localObject == null)
      return;
    ((InputMethodManager)localObject).hideSoftInputFromWindow(paramView.getWindowToken(), 0);
  }

  public boolean isMainProcess(int paramInt)
  {
    ActivityManager localActivityManager = (ActivityManager)getSystemService("activity");
    if (localActivityManager.getRunningAppProcesses() == null)
      return paramInt <= 0;
    if (paramInt <= 0);
    for (int i = android.os.Process.myPid(); ; i = paramInt)
    {
      Iterator localIterator = localActivityManager.getRunningAppProcesses().iterator();
      ActivityManager.RunningAppProcessInfo localRunningAppProcessInfo;
      do
      {
        boolean bool = localIterator.hasNext();
        str = null;
        if (!bool)
          break;
        localRunningAppProcessInfo = (ActivityManager.RunningAppProcessInfo)localIterator.next();
      }
      while (localRunningAppProcessInfo.pid != i);
      String str = localRunningAppProcessInfo.processName;
      return getPackageName().equals(str);
    }
  }

  public boolean isRooted()
  {
    return false;
  }

  public HashMap<String, String> ping(String paramString, int paramInt1, int paramInt2)
  {
    ArrayList localArrayList = new ArrayList();
    try
    {
      String str1 = "ping -c " + paramInt1 + " -s " + paramInt2 + " " + paramString;
      int m = paramInt2 + 8;
      localProcess = Runtime.getRuntime().exec(str1);
      BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localProcess.getInputStream()));
      String str2 = localBufferedReader.readLine();
      while (true)
        if (str2 != null)
        {
          label159: String str3;
          if (str2.startsWith(m + " bytes from"))
          {
            if (!str2.endsWith("ms"))
              break label212;
            str2 = str2.substring(0, -2 + str2.length()).trim();
            int n = str2.indexOf("time=");
            if (n > 0)
              str3 = str2.substring(n + 5).trim();
          }
          try
          {
            localArrayList.add(Float.valueOf(Float.parseFloat(str3)));
            str2 = localBufferedReader.readLine();
            continue;
            label212: if (!str2.endsWith("s"))
              break label159;
            str2 = str2.substring(0, -1 + str2.length()).trim() + "000";
          }
          catch (Throwable localThrowable2)
          {
            while (true)
              MobLog.getInstance().w(localThrowable2);
          }
        }
    }
    catch (Throwable localThrowable1)
    {
      java.lang.Process localProcess;
      MobLog.getInstance().d(localThrowable1);
      int i;
      int j;
      float f1;
      float f2;
      float f3;
      while (true)
      {
        i = localArrayList.size();
        j = paramInt1 - localArrayList.size();
        f1 = 0.0F;
        f2 = 0.0F;
        f3 = 0.0F;
        if (i <= 0)
          break label402;
        f3 = 3.4028235E+38F;
        for (int k = 0; k < i; k++)
        {
          float f4 = ((Float)localArrayList.get(k)).floatValue();
          if (f4 < f3)
            f3 = f4;
          if (f4 > f2)
            f2 = f4;
          f1 += f4;
        }
        localProcess.waitFor();
      }
      f1 /= i;
      label402: HashMap localHashMap = new HashMap();
      localHashMap.put("address", paramString);
      localHashMap.put("transmitted", String.valueOf(paramInt1));
      localHashMap.put("received", String.valueOf(i));
      localHashMap.put("loss", String.valueOf(j));
      localHashMap.put("min", String.valueOf(f3));
      localHashMap.put("max", String.valueOf(f2));
      localHashMap.put("avg", String.valueOf(f1));
      return localHashMap;
    }
  }

  public void showSoftInput(View paramView)
  {
    Object localObject = getSystemService("input_method");
    if (localObject == null)
      return;
    ((InputMethodManager)localObject).toggleSoftInputFromWindow(paramView.getWindowToken(), 2, 0);
  }

  private class GSConnection
    implements ServiceConnection
  {
    boolean got = false;
    private final BlockingQueue<IBinder> iBinders = new LinkedBlockingQueue();

    private GSConnection()
    {
    }

    public void onServiceConnected(ComponentName paramComponentName, IBinder paramIBinder)
    {
      try
      {
        this.iBinders.put(paramIBinder);
        return;
      }
      catch (Throwable localThrowable)
      {
        MobLog.getInstance().w(localThrowable);
      }
    }

    public void onServiceDisconnected(ComponentName paramComponentName)
    {
    }

    public IBinder takeBinder()
      throws InterruptedException
    {
      if (this.got)
        throw new IllegalStateException();
      this.got = true;
      return (IBinder)this.iBinders.poll(1500L, TimeUnit.MILLISECONDS);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.mob.tools.utils.DeviceHelper
 * JD-Core Version:    0.6.2
 */